home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr48 / sweep10.zip / HEAP.CPP next >
Text File  |  1993-04-01  |  790b  |  35 lines

  1. ////////////////
  2. // Heap Class //
  3. ////////////////
  4.  
  5. #include <alloc.h>
  6.  
  7. #include "sweep.h"
  8. #include "heap.hpp"
  9.  
  10. //////////////////////
  11. // Initialize heap. //
  12. //////////////////////
  13.  
  14. Heap::Heap (unsigned long s, unsigned b)
  15. {
  16.   void far * base;
  17.  
  18.   if (~s) s = farcoreleft();            // check if use all available
  19.   base = farmalloc (s);                 // allocate memory
  20.  
  21.   if (b)                                // if blocks specified
  22.     oldheap = HeapInitBlk (base, s, b); // initialize with block count
  23.   else
  24.     oldheap = HeapInit (base, s);       // initialize without block count
  25. }
  26.  
  27. /////////////////////
  28. // Terminate heap. //
  29. /////////////////////
  30.  
  31. Heap::~Heap()
  32. {
  33.   farfree (HeapSelect (oldheap));       // deallocate and switch to previous
  34. }
  35.